package com.hnust.dao;

import com.hnust.domain.GradRequirement;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface GradRequirementsDAO {

	/*
	 * @Author Tonited
	 * @Description //TODO
	 * @Date 16:40 2020/10/29
	 * @Param [id, maj_id专业id, num序号, content内容]
	 * @return Integet受影响的行数
	 **/
	@Insert("insert into grad_requirements values (#{id}, #{maj_id}, #{num}, #{content})")
	@ResultType(Integer.class)
	Integer addGradRequirement(String id, String maj_id, String num, String content);


	@Select("select grad_id from grad_requirements where maj_id=#{majId} and num=#{num}")
	String getIdByNumAndMajID(String num, String majId);

	@Select("select * from grad_requirements where maj_id=#{majId}")
	@ResultType(GradRequirement.class)
	List<GradRequirement> getGradRequirement(String majorId);
}
